Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Using INDEX-INFORMATION and a MESSAGE with a yes/no answer
Next, you need to check whether the field the user selected has an index. If not, you need to warn the user that the retrieval will not be indexed, and you need to provide the option of canceling the query.
![]()
To add this check and warning to your sample procedure:
- Use the
INDEX-INFORMATIONattribute of the query and aMESSAGEstatement that asks a question:
If
INDEX-INFORMATIONreturns "WHOLE-INDEX" for the first (and, in this case, the only) table in the query, then you know that there is no index Progress can use to retrieve the selected records, so it has to search the whole primary index.To give the user the option of canceling the query, you can use an option on the
MESSAGEstatement that you haven’t seen before. If you define aMESSAGEasVIEW-AS ALERT-BOX, you can define the choice buttons that appear in the alert box. As you have seen,OKis the default. Other choices areYES-NO,YES-NO-CANCEL,OK-CANCEL, andRETRY-CANCEL. You can thenSETa variable ofLOGICALdata type to record the answer. You can use a variable that you defined earlier or you can define it right in theMESSAGEstatement using theASLOGICALphrase. You can then check the value of the variable to see which choice the user picked. The first choice within any set of buttons returns yes, the second no, and if there is a third choice (as inYES-NO-CANCEL), clicking that button sets the variable to the Unknown value (?).(You can set other kinds of variables and fields in messages that aren’t defined as alert boxes, as well. See the online Help for details.)
In this case, if the user decides not to continue, the query is re-prepared using the
PREPARE-STRINGyou saved off earlier.- Reopen the query and
APPLY CHOOSEto the First button to display the first matching record and its Orders:
- Run the window. The Customer fields initially come up disabled:
![]()
- Click the Filter button. The fields are enabled and blanked out, and you can enter a value into any one of them:
![]()
- Enter a value into a nonindexed field, such as the City. You get a warning message:
![]()
- If you answer Yes, the query is prepared and opened:
![]()
If you answer No, the procedure reverts to the previous query or to the default query if this is the first time the query has been re-prepared.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |